import {createRouter, createWebHistory} from 'vue-router'
import Layout from '@/views/Layout/index.vue'
import Login from '@/views/Login/index.vue'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category/index.vue'
import Detail from '@/views/Detail/index.vue'
import Member from '@/views/Member/index.vue'
import Pay from '@/views/Pay/index.vue'
import Video from '@/views/Video/index.vue'
import PayBack from '@/views/PayBack/index.vue'
import UserInfo from '@/views/Member/components/UserInfo.vue'
import UserCenter from '@/views/Member/components/UserCenter.vue'


const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'layout',
            component: Layout,
            children: [{
                path: '',
                component: Home

            },
                {
                    path: 'category/:id',
                    component: Category

                },
                {
                    path: 'detail/:id',
                    component: Detail

                },
                {
                    path: 'pay/:id',
                    component: Pay

                },
                {
                    path: 'paycallback', // 注意路径，必须是paycallback
                    component: PayBack
                },
                {
                    path: 'video/:id', // 注意路径，必须是paycallback
                    component: Video
                },
                {
                    path: '/member',
                    component: Member,
                    children: [
                        {
                            path: '',
                            component: UserInfo
                        },
                        {
                            path: 'center',
                            component: UserCenter
                        }
                    ]
                }
            ]
        },
        {
            path: '/login',
            name: 'login',
            // route level code-splitting
            // this generates a separate chunk (About.[hash].js) for this route
            // which is lazy-loaded when the route is visited.
            component: Login
        }
    ]
})

export default router
